package application.caiji;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import newcontent.http.HttpClientUtil;

public class rengwu2 {

	public static void main(String[] args) throws Exception {
		String local="http://localhost:8080/datacollect_new/";
		String test="http://test.datacollect.cnbkw.com:8083/";
		String yufa="http://yufa.datacollect.cnbkw.com:8083/";

		ExecutorService service = Executors.newFixedThreadPool(15);
//		service.execute(new myThread(yufa+"/telsaleinfos/updateChange","size=2000&Initialize=1&index=133",2,false));
		
		String jsonstr="{\"subItemList\":[{\"id\":\"1756EA50-2784-4574-9F8D-C2847D7FE121\",\"parentId\":\"529C2D91-E2C4-4739-A248-A2727C849177\",\"sign\":\"9b66d2d237e56c8bb5b4\",\"name\":\"建设工程造价管理\",\"classType\":\"4\",\"subItemClassType\":null,\"subItemList\":null,\"shortTitle\":\"造价管理\",\"subjectType\":\"0\",\"typeIco\":null},{\"id\":\"0B9B004C-D6BF-4EBC-8486-B1178C186CE7\",\"parentId\":\"529C2D91-E2C4-4739-A248-A2727C849177\",\"sign\":\"a972a5ce590f45e832a1\",\"name\":\"建设工程计价\",\"classType\":\"4\",\"subItemClassType\":null,\"subItemList\":null,\"shortTitle\":\"计价\",\"subjectType\":\"0\",\"typeIco\":null},{\"id\":\"200A5559-A3CA-4635-8EF8-D2D8A4CD56EC\",\"parentId\":\"529C2D91-E2C4-4739-A248-A2727C849177\",\"sign\":\"1c71b4df22253a6d2e7f\",\"name\":\"技术与计量(土木建筑)\",\"classType\":\"4\",\"subItemClassType\":null,\"subItemList\":null,\"shortTitle\":\"土建计量\",\"subjectType\":\"1\",\"typeIco\":null},{\"id\":\"B7472A3D-7080-4F5D-A7DF-0C92A05C3ED1\",\"parentId\":\"529C2D91-E2C4-4739-A248-A2727C849177\",\"sign\":\"8fb10a8ac05b9e044a67\",\"name\":\"技术与计量(安装)\",\"classType\":\"4\",\"subItemClassType\":null,\"subItemList\":null,\"shortTitle\":\"安装计量\",\"subjectType\":\"1\",\"typeIco\":null},{\"id\":\"70281960-B20C-48F9-BD3C-0BA2CBEAC70D\",\"parentId\":\"529C2D91-E2C4-4739-A248-A2727C849177\",\"sign\":\"9685c474b5dd52f943dd\",\"name\":\"技术与计量(交通)\",\"classType\":\"4\",\"subItemClassType\":null,\"subItemList\":null,\"shortTitle\":\"交通计量\",\"subjectType\":\"1\",\"typeIco\":null},{\"id\":\"9CE472D0-4BAF-454B-A7FF-A9915B20B029\",\"parentId\":\"529C2D91-E2C4-4739-A248-A2727C849177\",\"sign\":\"372607e6edfeb84a689a\",\"name\":\"建设工程造价案例分析(土建+安装)\",\"classType\":\"4\",\"subItemClassType\":null,\"subItemList\":null,\"shortTitle\":\"土+安案例\",\"subjectType\":\"1\",\"typeIco\":null},{\"id\":\"A60B2646-B266-4EF2-9C0D-24F4DB020687\",\"parentId\":\"529C2D91-E2C4-4739-A248-A2727C849177\",\"sign\":\"5ee6ee1cdb439fcdedce\",\"name\":\"建设工程造价案例分析(交通)\",\"classType\":\"4\",\"subItemClassType\":null,\"subItemList\":null,\"shortTitle\":\"交通案例\",\"subjectType\":\"1\",\"typeIco\":null}]}";
		JSONObject parse = JSONObject.parseObject(jsonstr);
		JSONArray jsonArray = parse.getJSONArray("subItemList");
		System.out.println("科目列表："+jsonArray.size());
		for (int i = 0; i < jsonArray.size(); i++) {
			JSONObject object = jsonArray.getJSONObject(i);
			String subjectId = object.getString("id");
			System.out.println("subjectId:"+subjectId);
			if(i>=0) {
//				System.out.println("历年真题列表采集:");
//				String sendHttpGet = HttpClientUtil.sendHttpGet(local+"wangxiao/getTestPaperList"+"?"+"subjectId="+subjectId);
//				System.out.println(sendHttpGet);
			}
			if(i>=0) {
				System.out.println("历年真题试题采集:");
				String sendHttpGet="";
				while (sendHttpGet.indexOf("采集完成")<0) {
					sendHttpGet = HttpClientUtil.sendHttpGet(local+"wangxiao/getTestPaperQuestion"+"?");
					System.out.println(sendHttpGet);
				}
			}
		}
		service.shutdown();
	}

}
